package _02_linked_list;

import org.junit.Test;

/**
 * @author: mornd
 * @dateTime: 2023/5/30 - 21:22
 * 测试类
 */
public class MyTest {
    @Test
    public void test() {
        SinglyLinkedList linkedList = new SinglyLinkedList();
        linkedList.add(1);
        linkedList.add(2);
        linkedList.add(3);
        linkedList.insert(0,5);
//        linkedList.remove(3);
        System.out.println(linkedList);
//        for (Integer i : linkedList) {
//            System.out.println(i);
//        }
//        linkedList.foreach(System.out::println);
    }
    @Test
    public void testLoop() {
        SinglyLinkedList linkedList = new SinglyLinkedList();
        linkedList.add(1);
        linkedList.add(2);
        linkedList.add(3);
        linkedList.loop((i) -> {
            System.out.println("模拟前置拦截器，序号为：" + i);
        }, (i) -> {
            System.out.println("模拟后置拦截器，序号为：" + i);
        });

    }

    @Test
    public void test2() {
        SinglySentinelLinkedList list = new SinglySentinelLinkedList();
        list.add(1);
        list.add(2);
        list.add(3);
        System.out.println(list.get(0));
        System.out.println(list.get(1));
        System.out.println(list.get(2));
        System.out.println(list.get(3));
        System.out.println(list);
    }

    @Test
    public void test3() {
        DoublyLinkedListSentinel<Integer> list = new DoublyLinkedListSentinel<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
//        list.add(3);
//        list.addFirst(4);
//        list.insert(0,5);
//        list.insert(2,6);
//        System.out.println(list);
        list.forEach(System.out::println);
    }

    @Test
    public void test4() {
        DoublyRingLinkedListSentinel<Integer> list = new DoublyRingLinkedListSentinel<>();
        list.add(0,1);
        list.add(0,2);
        list.add(0,3);
        System.out.println(list);

    }
}
